package com.story.aistory.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;

import lombok.Getter;
import org.apache.coyote.BadRequestException;

//enum('简单', '中等', '困难', '毛线')
@Getter
public enum GameDeficult {
    YARN(1, "毛线"),
    EASY(2, "简单"),
    MEDIUM(3, "中等"),
    HARD(4, "困难"),

    ;
    @EnumValue
    int value;
    String desc;

    GameDeficult(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static GameDeficult of(int value) throws BadRequestException {
        if (value == 1) {
            return EASY;
        }
        if (value == 2) {
            return MEDIUM;
        }
        if (value == 3) {
            return HARD;
        }
        if (value == 4) {
            return YARN;
        }
        throw new BadRequestException("Invalid game difficult value: ");
    }
}